home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / AMAL / AMAL_2.AMOS / AMAL_2.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  6.3 KB  |  192 lines

  1. '*************************** 
  2. '*    AMOS Professional    * 
  3. '*                         * 
  4. '*         AMAL_2          *               Amal Registers
  5. '*                         * 
  6. '* (c) Europress Software  * 
  7. '*                         * 
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'Internal registers
  13. '------------------------------------------- 
  14. 'Each Amal channel has its own set of internal registers which operate like
  15. 'local variables and can hold values in the range of -32768 to 32767.
  16. 'There are 10 for each channel named R0-R9 and these can hold different
  17. 'values in each amal program.
  18. '------------------------------------------- 
  19. 'The Amal Let instruction  
  20. '------------------------------------------- 
  21. 'keyword L 
  22. '  
  23. 'Values are assigned to the amal registers with the Amal Let or L in a 
  24. 'similar manner to normal basic variables. 
  25. '
  26. 'eg.      Let R0=200        Let R2=R0         LR3=R3+1 
  27. '
  28. '------------------------------------------- 
  29. 'External registers
  30. '------------------------------------------- 
  31. 'In addition to the internal registers R0-R9 which are local to each Amal
  32. 'program there is also a set of registers for holding values which are common
  33. 'to all Amal programs and allow values to be shared between them. These
  34. 'registers are accessed with the letter R being followed this time by a
  35. 'second letter A-Z giving a total of 26 external registers RA-RZ.
  36. '
  37. 'eg.      Let RA=100        Let RA=R0         LRX=RX+1 
  38. '
  39. '------------------------------------------- 
  40. 'The Amal For To Next loop 
  41. '------------------------------------------- 
  42. 'Keywords F T N
  43. '
  44. 'This is the Amal version of the basic For...Next loop which can be used in
  45. 'conjunction with both the internal and external registers. Unlike normal
  46. 'Basic the step size can not be changed and is always set to 1.
  47. 'One step of the loop will be performed per vertical blank (1/50th. of a 
  48. 'second) and the appropriate register name must follow each Next.  
  49. '
  50. 'eg.      For R0=1 To 100; Next R0      (FR0=1T100;NR0)  
  51. '
  52. '------------------------------------------- 
  53. 'Special registers 
  54. '------------------------------------------- 
  55. 'There are 3 special registers which can be used to set or test your objects 
  56. 'status. 
  57. '
  58. '            X   (holds the objects X coordinate)
  59. '            Y   (holds the objects Y coordinate)
  60. '            A   (image number of the object)
  61. '
  62. 'Changing registers X and Y inside an Amal program will move your object 
  63. 'around the screen:- 
  64. '
  65. '            Let X=160;Let Y=Y+1                  (LX=160;LY=Y+1)  
  66. '            For R0=1 To 200;Let X=R0;Next R0     (FR0=1T200;LX=R0;NR0)  
  67. '
  68. 'Changing the A register value will change the appearance of your object 
  69. 'to the shape of that image number taken from the sprite bank, allowing  
  70. 'complex and synchronised animations to take place.
  71. '
  72. 'eg.         Let A=2 
  73. '            For R5=1 To 10;Let A=R5;Next R5      (FR5=1T10;LA=R5;NR5) 
  74. '
  75. '------------------------------------------- 
  76. 'Amal If instruction 
  77. '------------------------------------------- 
  78. 'Keyword I 
  79. '
  80. 'This is the Amal conditional test which allows control to be jumped to
  81. 'another part of your Amal program if the test is True (-1) otherwise Amal 
  82. 'will continue with the next instruction.
  83. '
  84. 'eg.      A: Let R0=20; B: Let R0=R0-1;Let X=R0;If R0<1 Jump B;Jump A
  85. '
  86. '------------------------------------------- 
  87. 'Amal Pause instruction
  88. '------------------------------------------- 
  89. 'Keyword P   
  90. '
  91. 'Pause halts your Amal program until the next verticl blank and frees
  92. 'processor time for your Basic program. It is most frequently used before
  93. 'a Jump instruction to avoid over-stepping the maximum of 10 jumps per Vbl.
  94. 'This instruction if used wisely and can have a dramatic effect on the speed 
  95. 'of your Basic program.
  96. '
  97. 'eg.      A: Let X=X+1;Pause Jump A       (A: LX=X+1;PJA)    
  98. '
  99. '------------------------------------------- 
  100. 'Amreg 
  101. '------------------------------------------- 
  102. 'This function allows access to the Amal registers from within your Basic
  103. 'program, values can be written to or read depending on the syntax used. 
  104. '
  105. 'Reading a value from an external register:- 
  106. '
  107. '             V=Amreg(0) 
  108. '
  109. 'The number in brackets denotes which register is to be read and can be in 
  110. 'the range of 0-25 representing the registers RA-RZ with 0=RA, 1=RB etc. etc.
  111. '
  112. 'Writing a value to an external register:- 
  113. '              
  114. '             Amreg(0)=V 
  115. '
  116. 'The number in brackets once again denotes which register is to be accessed. 
  117. '
  118. 'By adding an optional channel number the internal registers can be read:- 
  119. '
  120. '                     +--->channel number to be accessed 
  121. '                     | +--->register number 0-9 representing R0-R9
  122. '             V=Amreg(1,0)   
  123. '
  124. 'A similar syntax is used to assign a value to the internal registers:-
  125. '
  126. '               Amreg(9,1)=V 
  127. '
  128. '------------------------------------------- 
  129. 'EXAMPLE 
  130. '------------------------------------------- 
  131. Auto View Off 
  132. Rem *** load some objects to work with and clear the screen
  133. '
  134. Load "AmosPro_Tutorial:Objects/Amal_Bobs.abk"
  135. Screen Open 0,320,200,16,Lowres : Flash Off 
  136. Get Sprite Palette : Curs Off : Cls 0 : Hide 
  137. '
  138. Rem *** Amal program for moving both guns
  139. '
  140. A$="Label: Move142,0,142;Move -142,0,142;Pause Jump Label"
  141. '
  142. Rem *** Left gun fire uses external register RA (Amreg(0)) 
  143. '
  144. B$="Anim 0,(9,2)(10,2);LetRA=1;Move0,-200,25;LetRA=0"
  145. '
  146. Rem *** Right gun fire uses internal register R5 (Amreg(Channel,5))
  147. '
  148. C$="Anim 0,(9,2)(10,2);LetR5=1;Move0,-200,50;LetR5=0"
  149. '
  150. Rem *** set start positions of computed sprites
  151. '
  152. Sprite 8,128,218,11
  153. Sprite 9,282,218,11
  154. Sprite 10,0,218,9
  155. Sprite 11,0,218,9
  156. '
  157. Rem *** assign Amal channels to the strings
  158. Amal 10,B$
  159. Amal 11,C$
  160. Amal 8,A$
  161. '
  162. Rem *** start left gun moving
  163. '
  164. Amal On 8
  165. '
  166. Rem *** Print text 
  167. '
  168. Paper 0 : Locate 0,3 : Centre "Press left mouse key to fire left gun"
  169. Pen 7 : Locate 0,6 : Centre "Press right mouse key to fire right gun"
  170. Pen 8 : Locate 0,9 : Centre "Press both to quit"
  171. '
  172. Rem *** short delay before starting right gun
  173. '
  174. Wait 60
  175. Amal 9,A$
  176. Amal On 9
  177. '
  178. Rem *** start the main basic loop to check the registers 
  179. '
  180. View 
  181. Do 
  182.    If Mouse Key=3 Then Direct 
  183.    If Amreg(0)=0 and Mouse Key=1 : Shoot 
  184.       Sprite 8,,,12 : Wait 4 : Sprite 8,,,11
  185.       Sprite 10,X Sprite(8),206,9 : Amal 10,B$ : Amal On 10
  186.    End If 
  187.    If Amreg(11,5)=0 and Mouse Key=2 : Boom 
  188.       Sprite 9,,,12 : Wait 4 : Sprite 9,,,11
  189.       Sprite 11,X Sprite(9),206,9 : Amal 11,C$ : Amal On 11
  190.    End If 
  191.    Wait 3
  192. Loop